using System.Collections;

namespace CSharpPro._1020;

public class Demo
{
    public void TestPrint()
    {
        int[] arr = new int[10];
        arr[0] = 1;
        arr[4] = 5;
        Console.WriteLine(arr[6]);
        String[] arr2 = new String[5];
        arr2[0] = "1";
        arr2[4] = "5";
        //Console.WriteLine(arr2[6]);
        int[] arr3 = { 1, 2, 3, 4 };
        //二维数组
        int[,] arr4 = new int[2, 3];
        arr4[0, 0] = 1;
        arr4[1, 2] = 2;
        string[,] arr5 =
        {
            { "1", "2", "3" },
            { "4", "5", "6" },
            { "7", "8", "9" }
        };
        int[] arr6 = { 11, 22, 4, 66, 33 };
        Array.Sort(arr6);//升序
        Array.Reverse(arr6);//降序
        foreach (int i in arr6)
        {
            Console.WriteLine(i+"\t");
        }
        Student[]  students = new Student[5];
            students[0] = new Student();
            // .var创建变量名
            ArrayList list = new ArrayList();
            var hashtable = new Hashtable();
            list.AddRange(arr6);
            list.Add(9);
            list.Add("abc");
            Console.WriteLine();
            foreach (object o in list)
            {
                Console.Write(o+"\t");
            }
            list.Remove(66);
            list.RemoveAt(index:2);
            list.RemoveRange(index:2,count: 2);
            Console.WriteLine();
            foreach (object o in list)
            {
                Console.Write(o+"\t");
                hashtable.Add("1","111");
                hashtable.Add("2","222");
                hashtable.Add("3","333");
                Console.WriteLine(hashtable["1"]);
                foreach (DictionaryEntry entry in hashtable)
                {
                    Console.WriteLine(entry.Key+"---"+entry.Value);
                }
                hashtable.Remove("2");
            }
    }
}